package com.wu.search.schedule;

import com.wu.search.cache.SuggestWordCache;
import com.wu.search.vo.SuggestResp;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Cousin
 * @date 2025/3/28
 * @Description
 */
@Component
public class SuggestWordBaseSchedule {
    @PostConstruct
    public void onStartup() {
        // 启动时立即调用任务
        updateSuggestWord();
    }
    @Scheduled(cron = "0 0 0 * * ?")
    public void updateSuggestWord(){
        List<SuggestResp> list = new ArrayList<>();
        SuggestResp suggestResp = new SuggestResp();
        suggestResp.setKeyword("权志龙");
        suggestResp.setCount(100000000L);
        list.add(suggestResp);
        SuggestResp suggestResp1 = new SuggestResp();
        suggestResp1.setKeyword("跳楼机");
        suggestResp1.setCount(100000000L);
        list.add(suggestResp1);
        SuggestResp suggestResp2 = new SuggestResp();
        suggestResp2.setKeyword("小丑竟是我自己");
        suggestResp2.setCount(100000000L);
        list.add(suggestResp2);
        SuggestWordCache.getInstance().setSuggestRespList(list);
    }

}
